#ifndef PINGPONG_H
#define PINGPONG_H

#include <QtGui>
#include "ball.h"
#include "paddle.h"
#include "optionsdialog.h"
#include "ai_pingpong.h"
#include <QtOpenGL>

#ifdef Q_WS_X11
 #include <phonon/mediaobject.h>
 #include <phonon/audiooutput.h>
#endif

#ifdef Q_WS_WIN
 #include <Phonon/MediaObject>
 #include <Phonon/AudioOutput>
#endif


class pingpong : public QWidget
{
    Q_OBJECT
    public:
        pingpong(QWidget *parent = 0);
        void initGameObjects();
        void initScene();
        void initMenuButtons();
        void initLabels();
        void resetLabels();
        void initView();
        void initTimers();
        void changeTimerStatus();
        void initPhonon();
        void initOptions();
        void resetRenewableGameObjects();
        void setLayouts();
        void keyPressEvent ( QKeyEvent * event  );
        void gameOver();
        void openHighscores();
       ~pingpong();
   public slots:
        void newGame();
        void newRound(bool player1Won);
        void startingNewRound();
        void openOptions();
        void updateTimeDisplay();
        void settingsChanged();
        void pausingProcedure();
        void updateScore(int addScore);
        void playCollisionSound();
    private:
       Phonon::MediaObject *bounceSound, *winSound, *lostSound;
       Phonon::AudioOutput *aani;
       QGraphicsScene *scene;
       QGraphicsView *view;
       QGraphicsLineItem *topBorder, *bottomBorder,*leftBorder,*rightBorder;
       QGraphicsTextItem *pausedText, *gameStatusText;
       QPushButton *newgameButton,*optionsButton,*highscoreButton;
       QLabel *playerInfoLabel, *timeInfoLabel, *scoreInfoLabel, *livesInfoLabel;
       QLabel *playerNameLabel, *timeLabel, *scoreLabel, *livesLabel;
       QVBoxLayout *buttonLayout, *labelLayout;
       QHBoxLayout *mainLayout;
       Ball *playball;
       Paddle *player1paddle,*player2paddle;
       AI_pingpong *ai;
       OptionsDialog *optionsDialog;
       QTimer *timer, *timeDisplay;
       int time, livesLeft;
       bool paused, firstRun, newRoundBeginning;
};

namespace MathOperations
{
    double getAngleXYOrigin(QPointF xy, QPointF origin, bool revertedY);
    int getRandomAngle();
};

#endif // PINGPONG_H
